#!/bin/bash
hive_db_name=cy_database
mysql_db_name=???

export_data(){
/home/software/sqoop-1.4.7/bin/sqoop import \
--connect jdbc:mysql://192.168.1.90:3306/$mysql_db_name \
--username changyuan \
--password tecsunBD@2020 \
--table $1 \
--num-mappers 1 \
--export-dir /warehouse/cy_database/ads/$1 \
--input-fields-terminated-by ";" \
--update-mode allowinsert \
--update-key $2 \
--input-null-string '\\N' \
--input-null-non-string '\\N'
}

case $1 in
  "ads_uv_count")
     export_data "ads_uv_count" "dt"
;;
  "ads_user_action_convert_day")
     export_data "ads_user_action_convert_day" "dt"
;;
  "ads_gmv_sum_day")
     export_data "ads_gmv_sum_day" "dt"
;;
  "ads_user_topic")
     export_data "ads_user_topic" "dt"
;;
   "all")
     export_data "ads_uv_count" "dt"
     export_data "ads_user_action_convert_day" "dt"
     export_data "ads_gmv_sum_day" "dt"
     export_data "ads_user_topic" "dt"
;;
esac